import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton } from '../Common/options'
import { OrganizationIdentityLevel } from '../Common/Conversion'

export const ProjectOperationPaymentPlan = async ({ url, OptionsEvent, ClientData, Permission }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}OC`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            Permission.findIndex(v => v.uuid === '2bacbe08-727e-4cc6-b70d-e2dad3815bff') !== -1 && (
                <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />
            ),
        ],
        columns: [
            commonTableList.uuid,
            { ...commonTableList.tableName },
            { ...commonTableList.code, hideInSearch: true },
            {
                dataIndex: 'organizationUuid',
                title: '项目名称',
                valueType: 'select',
                valueEnum: await OrganizationIdentityLevel(4),
                rules: true,
                width: 450,
            },

            {
                dataIndex: 'maintainPayment',
                title: '养护费用(万元)',
                valueType: 'inputNumber',
                hideInSearch: true,
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'loanPayment',
                title: '偿还贷款金额(万元)',
                valueType: 'inputNumber',
                hideInSearch: true,
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'managePayment',
                title: '管理费(万元)',
                valueType: 'inputNumber',
                hideInSearch: true,
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'taxPayment',
                title: '税金(万元)',
                valueType: 'inputNumber',
                hideInSearch: true,
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'shareholderPayment',
                title: '股东分红(万元)',
                valueType: 'inputNumber',
                hideInSearch: true,
                rules: true,
                width: 150,
            },
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 200,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === '5aa9aa40-652f-4efa-948f-732775a9ba83') !== -1 && (
                            <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />
                        ),
                        Permission.findIndex(v => v.uuid === '2f177282-dbeb-481d-bf63-5460fe1aa662') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="del"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return data
}
